<template>
  <div>
    <el-container class="home-container">
      <el-header>
        <el-row>
          <el-col span="12">
            <span class="logoText">软件公司</span>
            <span class="logoText2">员工考勤管理系统</span>
          </el-col>
          <el-col span="12">
            <el-button type="success" icon="el-icon-check" circle></el-button>
            <el-popover :data="gridData"
                        placement="bottom"
                        title="通知"
                        width="200"
                        trigger="click">
              <el-button slot="reference" type="warning" icon="el-icon-star-off" circle></el-button>
            </el-popover>
          </el-col>
        </el-row>
      </el-header>










      <el-container>



        <el-aside>
          <el-row>
            <el-col span="12" style="height: 50px">
            <el-avatar shape="square" :size="50" :src="squareUrl"></el-avatar>
            </el-col>
            <el-col span="12" style="height: 70px">
              <span style="color: #1abc9c">
                ●
              </span>
              <span style="color: #cfcfcf">
                {{username}}
              </span>
              <el-button size="mini" @click="logout">登出</el-button>
            </el-col>
          </el-row>
          <el-menu
                  default-active="2"
                  class="el-menu-vertical-demo"
                  @open="handleOpen"
                  @close="handleClose"
                  background-color="#545c64"
                  text-color="#fff"
                  active-text-color="#ffd04b"
          >

            <!--权限控制-->
            <!--超级管理员-->
            <div v-show="mylevel === String(0)?true:false">
              <router-link to="/userInfo">
                <el-menu-item index="1">
                  <i class="el-icon-menu"></i>
                  <span slot="title">用户管理</span>
                </el-menu-item></router-link>
              <router-link to="/department">
                <el-menu-item index="1">
                  <i class="el-icon-menu"></i>
                  <span slot="title">部门管理</span>
                </el-menu-item></router-link>
              <router-link to="/log">
                <el-menu-item index="2">
                  <i class="el-icon-menu"></i>
                  <span slot="title">操作日志</span>
                </el-menu-item></router-link>
            </div>

            <!--经理-->
            <div v-show="mylevel === String(1)?true:false">
              <router-link to="/userInfo">
                <el-menu-item index="1">
                  <i class="el-icon-menu"></i>
                  <span slot="title">用户管理</span>
                </el-menu-item></router-link>
              <router-link to="/department">
                <el-menu-item index="1">
                  <i class="el-icon-menu"></i>
                  <span slot="title">部门管理</span>
                </el-menu-item></router-link>
              <router-link to="/daily">
                <el-menu-item index="1">
                  <i class="el-icon-menu"></i>
                  <span slot="title">日报管理</span>
                </el-menu-item></router-link>
              <router-link to="/overtime">
                <el-menu-item index="1">
                  <i class="el-icon-menu"></i>
                  <span slot="title">加班审批</span>
                </el-menu-item></router-link>
              <router-link to="/overtimeAudit">
                <el-menu-item index="1">
                  <i class="el-icon-menu"></i>
                  <span slot="title">审批</span>
                </el-menu-item></router-link>
            </div>

            <!--用户-->
            <div v-show="mylevel === String(2)?true:false">
              <router-link to="/daily">
                <el-menu-item index="1">
                  <i class="el-icon-menu"></i>
                  <span slot="title">日报</span>
                </el-menu-item></router-link>
              <router-link to="/overtime">
                <el-menu-item index="1">
                  <i class="el-icon-menu"></i>
                  <span slot="title">加班</span>
                </el-menu-item></router-link>
            </div>






          </el-menu>
        </el-aside>






        <el-main>
          <router-view/>
        </el-main>





      </el-container>





      <el-footer></el-footer>
    </el-container>
  </div>
</template>

<script>
  export default {
    name: "Home",
    data() {
      return {
        isCollapse: true,
        visible: false,
        gridData: 'sdsd',
        username: window.sessionStorage.getItem('name'),
        mylevel: window.sessionStorage.getItem('mylevel'),
        state: window.sessionStorage.getItem('state')
      };
    },
    created() {
    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      logout() {
        window.sessionStorage.removeItem('token')
        this.setCookie("", "", -1)
        this.$router.push('/login')
      },
      setCookie(username, password, existDay) {
        let exDate = new Date(); // 获取目前时间
        exDate.setTime(exDate.getTime() + 24 * 60 * 60 * 1000 * existDay); // 保存天数
        window.document.cookie = "userName" + "=" + username + ";path=/;expires=" + exDate.toGMTString();
        window.document.cookie = "userPwd" + "=" + password + ";path=/;expires=" + exDate.toGMTString();
      }
    }
  }
</script>

<style scoped>
  .el-header {
    background: #333333;
    text-align: center;
    line-height: 60px;
    min-height: 80px;
  }

  .el-footer {
    background: #333333;
    text-align: center;
    line-height: 60px;
  }

  .el-aside {
    background: #545c64;
    min-height: calc(100vh - 140px);
  }
  .el-menu {
    border-right: 0px;
  }

  .el-main {
    background: #fff;
  }

  .el-image {
    top: 5px;
  }

  .logoText {
    text-align: center;
    color: #fff;
    font-size: 30px;
  }
  .logoText2 {
    text-align: center;
    color: tan;
    font-size: 30px;
  }

  .userData {
    max-height: 50px;
  }
</style>
